package io.kiki.stack.http.feign;

import java.util.List;

import static io.kiki.stack.http.feign.Util.checkNotNull;

public class MethodHandlerConfiguration {

    private final MethodMetadata methodMetadata;

    private final Target<?> target;

    private final Retryer retryer;

    private final List<RequestInterceptor> requestInterceptorList;

    private final Logger logger;

    private final Logger.Level logLevel;

    private final RequestTemplateFactory buildTemplateFromArgs;

    private final Request.Options options;

    private final ExceptionPropagationPolicy exceptionPropagationPolicy;

    public MethodHandlerConfiguration(MethodMetadata methodMetadata, Target<?> target, Retryer retryer, List<RequestInterceptor> requestInterceptorList, Logger logger, Logger.Level logLevel, RequestTemplateFactory buildTemplateFromArgs, Request.Options options, ExceptionPropagationPolicy exceptionPropagationPolicy) {
        this.target = checkNotNull(target, "target");
        this.retryer = checkNotNull(retryer, "retryer for %s", target);
        this.requestInterceptorList = checkNotNull(requestInterceptorList, "requestInterceptors for %s", target);
        this.logger = checkNotNull(logger, "logger for %s", target);
        this.logLevel = checkNotNull(logLevel, "logLevel for %s", target);
        this.methodMetadata = checkNotNull(methodMetadata, "metadata for %s", target);
        this.buildTemplateFromArgs = checkNotNull(buildTemplateFromArgs, "metadata for %s", target);
        this.options = checkNotNull(options, "options for %s", target);
        this.exceptionPropagationPolicy = exceptionPropagationPolicy;
    }

    public MethodMetadata getMethodMetadata() {
        return methodMetadata;
    }

    public Target<?> getTarget() {
        return target;
    }

    public Retryer getRetryer() {
        return retryer;
    }

    public List<RequestInterceptor> getRequestInterceptorList() {
        return requestInterceptorList;
    }

    public Logger getLogger() {
        return logger;
    }

    public Logger.Level getLogLevel() {
        return logLevel;
    }

    public RequestTemplateFactory getBuildTemplateFromArgs() {
        return buildTemplateFromArgs;
    }

    public Request.Options getOptions() {
        return options;
    }

    public ExceptionPropagationPolicy getExceptionPropagationPolicy() {
        return exceptionPropagationPolicy;
    }
}
